+Mon Jun 1 04:43:27 1998 Tim Janik <timj@gtk.org>
+
+ * ghash.c (g_hash_table_insert): wrote a comment describing why
+ a hash node's key should not also get replaced when overriding
+ previous entries.
+
+Tue May 26 18:30:06 1998 Tim Janik <timj@gtk.org>
+
+ * glib.h (g_string_sized_new): new function to controll the preallocated
+ size of a GString.
+
+ * glib.h (g_strreversed): new function to reverse a string.
+
Mon May 18 22:14:39 1998 Owen Taylor <otaylor@gtk.org>
(Yasuhiro SHIRASAKI <joke@awa.tohoku.ac.jp> : gtk-joke-980517-0.patch)
(* rhash_table->key_compare_func) (node->key, key)) ||
(node->key == key))
{
+ /* do not reset node->key in this place, keeping
+ * the old key might be intended.
+ * a g_hash_table_remove/g_hash_table_insert pair
+ * can be used otherwise.
+ *
+ * node->key = key;
+ */
node->value = value;
return;
}
const gchar *s2);
void g_strdown (gchar *string);
void g_strup (gchar *string);
+void g_strreverse (gchar *string);
guint g_parse_debug_string (const gchar *string,
GDebugKey *keys,
guint nkeys);
/* Strings
*/
GString* g_string_new (const gchar *init);
+GString* g_string_sized_new (guint dfl_size);
void g_string_free (GString *string,
gint free_segment);
GString* g_string_assign (GString *lval,
gpointer func_data);
void g_scanner_remove_symbol (GScanner *scanner,
const gchar *symbol);
+void g_scanner_freeze_symbol_table (GScanner *scanner);
+void g_scanner_thaw_symbol_table (GScanner *scanner);
void g_scanner_unexp_token (GScanner *scanner,
GTokenType expected_token,
const gchar *identifier_spec,
{
register GScannerHashVal *hash_val;
- g_return_if_fail (symbol != NULL);
g_return_if_fail (scanner != NULL);
+ g_return_if_fail (symbol != NULL);
hash_val = g_scanner_lookup_internal (scanner, symbol);
{
register GScannerHashVal *hash_val;
+ g_return_if_fail (scanner != NULL);
+
hash_val = g_scanner_lookup_internal (scanner, symbol);
if (hash_val)
}
}
+void
+g_scanner_freeze_symbol_table (GScanner *scanner)
+{
+ g_return_if_fail (scanner != NULL);
+
+ g_hash_table_freeze (scanner->symbol_table);
+}
+
+void
+g_scanner_thaw_symbol_table (GScanner *scanner)
+{
+ g_return_if_fail (scanner != NULL);
+
+ g_hash_table_thaw (scanner->symbol_table);
+}
+
GTokenType
g_scanner_peek_next_token (GScanner *scanner)
{
}
GString*
-g_string_new (const gchar *init)
+g_string_sized_new (guint dfl_size)
{
GRealString *string;
string = g_chunk_new (GRealString, string_mem_chunk);
- string->alloc = 2;
+ string->alloc = 0;
string->len = 0;
- string->str = g_new0(char, 2);
+ string->str = NULL;
- if (init)
- g_string_append ((GString*)string, init);
+ g_string_maybe_expand (string, MAX (dfl_size, 2));
+ string->str[0] = 0;
return (GString*) string;
}
+GString*
+g_string_new (const gchar *init)
+{
+ GString *string;
+
+ string = g_string_sized_new (2);
+
+ if (init)
+ g_string_append (string, init);
+
+ return string;
+}
+
void
g_string_free (GString *string,
gint free_segment)
}
}
+void
+g_strreverse (gchar *string)
+{
+ g_return_if_fail (string != NULL);
+
+ if (*string)
+ {
+ register gchar *h, *t;
+
+ h = string;
+ t = string + strlen (string) - 1;
+
+ while (h < t)
+ {
+ register gchar c;
+
+ c = *h;
+ *h = *t;
+ h++;
+ *t = c;
+ t--;
+ }
+ }
+}
+
gint
g_strcasecmp (const gchar *s1,
const gchar *s2)